<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app1"></div>

  <script src="../js/react.development.js"></script>
  <script src="../js/react-dom.development.js"></script>
  <script src="../js/babel.min.js"></script>
  <script src="../js/prop-types.js"></script>

  <script type="text/babel">
    class Demo extends React.Component {
     
     state = {
       isHot:true
     }

      showData = () => {
        const{ input1 } = this
        alert(input1.value)
      }
      changeWeather = ()=>{
        const {isHot} = this.state
        this.setState({
          isHot:!isHot
        })
      }
      saveInput = (c)=>{
        this.input1 = c
        console.log('c',c);
      }
      render() {
        const { isHot } = this.state
        return (
          <div>
            <h2>今天天气 {isHot?'炎热':'凉爽'}</h2>
            {/*<input ref={c=>{this.input1 = c;console.log('ref',c);}}  type="text" placeholder="点击提示数据"/>*/}
            <input ref={this.saveInput}  type="text" placeholder="点击提示数据"/>
            <button  onClick={this.showData}>点我提示数据</button>
            <button  onClick={this.changeWeather}>点我改变天气</button>
          </div>
        )
      }
    }

    ReactDOM.render(<Demo />, document.getElementById("app1"))
  </script>
</body>

</html>